<template>
	<div>
		<headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave>
		<components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
	</div>
</template>
<script>
	import $ from 'jquery'
	import headerNave from '../../../../components/headerNave'
	import { GloabFun, Animation, HttpServer } from '../../../../assets/js/common.js'
	//层架列表
	const List = resolve => require(['./List.vue'], resolve)
	//层架书籍信息
	const DistrictBookList = resolve => require(['./BookList.vue'], resolve)
	//位置
	const DistrictReaderList = resolve => require(['./ReaderList.vue'], resolve)
	export default {
		components: {
			List,
			DistrictBookList,
			DistrictReaderList,
			headerNave
		},
		data() {
			return {
				currentView: "List",
				templateObj: {
					// DistrictId: this.subArgs.DistrictId,
					CurrentView: this.subArgs.CurrentView
				},
				navDatas: [{
						name: '图书流通',
						view: ""
					},
					{
						name: this.subArgs.CurrentView,
						view: "List"
					}
				]
			};
		},
		props: {
			subArgs: {
				type: Object,
				default: {}
			}
		},
		methods: {
			changeView(view, obj) {
				GloabFun.clearRecordPreview.call(this);
				// obj.DistrictId = this.subArgs.DistrictId;
				obj.CurrentView = this.subArgs.CurrentView;
				Animation.animation($("#mainContent"), function() {
					if(obj) {
						this.navDatas = [{
								name: '图书流通',
								view: ""
							},
							{
								name: this.subArgs.CurrentView,
								view: "List"
							}
						];
						this.templateObj = obj;
						if(view === "DistrictBookList") {
							this.navDatas.push({
								name: '图书信息->' + obj.Name,
								view: "DistrictBookList"
							});
						} else if(view === "DistrictReaderList") {
							this.navDatas.push({
								name: '读者信息->' + obj.Name,
								view: "DistrictReaderList"
							});
						}
						// else if(view==="miniLibrary1Detail"){
						//   this.navDatas.push({
						//       name:obj.Title,
						//       view:"miniLibrary1Detail"
						//    });
						// }
					}
					this.currentView = view;
				}.bind(this));
			},
			backPrev() {
				this.$emit('backPrev');
			},
			backNav(item) {
				if(item.view === "List") {
					this.changeView("List", this.templateObj);
				}
			}
		}
	}
</script>